package wishes;

import enums.WishType;
import interfaces.AbstractDrink;
import interfaces.AbstractWish;
import model.Model;

public class WishToDrink extends AbstractWish {

	private AbstractDrink drink;
	public WishToDrink(long startTime, AbstractDrink drink) {
		super(startTime);
		this.drink = drink;
	}

	public boolean canBeFulfilled() {
		return drink.hasEnoughDishes() && drink.hasEnoughIngredients();
	}

	public long getDeadLine() {
		return getStartTime() + Model.ZEIT_STUNDE;
	}

	public AbstractDrink getDrink() {
		return drink;
	}

	public boolean fulfill() {
		if (canBeFulfilled()) {
			Model.getInstance().drink(drink);
			Model.getInstance().getWishes().remove(this);
			return true;
		} 
		return false;
	}

	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("bis ").append(Model.millisToString(getDeadLine()));
		builder.append(" >> Will trinken (").append(drink.getName()).append(")");
		return builder.toString();
	}

	@Override
	public WishType getType() {
		return WishType.WishToDrink;
	}
}